package com.hcm.sk.controller;

import com.hcm.sk.service.IUserService;
import com.hcm.sk.vo.LoginVo;
import com.hcm.sk.vo.ResponseBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.print.DocFlavor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @description: LoginController
 * @date: 2021/1/25 17:01
 * @author: hcm
 * @version: 1.0
 */
@Controller
@RequestMapping("/login")
@Slf4j
public class LoginController {

    @Autowired
    IUserService service;

    /**
     * toLogin 跳转登录
     */
    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }

    /**
     * 登录功能
     * @param loginVo
     * @return
     */
    @RequestMapping("/doLogin")
    @ResponseBody
    public ResponseBean doLogin(@Valid LoginVo loginVo , HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){

        return service.doLogin(loginVo,httpServletRequest,httpServletResponse) ;
    }

}
